<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="sockjs.min.js"></script>
    <script src="stomp.min.js"></script>
    <script src="jquery.min.js"></script>
</head>
<body>
<script>
    let url = 'marcopolo';
    let sock = new SockJS(url);
    let stomp=Stomp.over(sock);

    let payload = JSON.stringify({'message':'Marco!'});

    let max=0;
    let sum=0;
    let count=0;
    let average=0;
    stomp.connect('guest','guest',function(frame){
        stomp.send("/app/marco",{},payload);
        stomp.subscribe('/topic/test', function(message){
            let end=new Date().getTime();
            let obj=JSON.parse(message.body);
            let start=parseInt(obj.MSG);
            let spend=end-start;
            count++;
            max=max>spend?max:spend;
            sum=sum+spend;
            average=sum/count;
            console.log(message.body)
            $("#total").html(`count=${count},average=${average},max=${max}`);
            if($("#show li").length==0)
                $("#show").append(`<li>${message.body}</li>`);
            else
            $(`<li>${message.body}</li>`).insertBefore($("#show li")[0]);

        });
    });


</script>
<a id="total"></a>
<ol id="show">
</ol>
</body>
</html>